package cc.autoapi.pucong.auto.flow.core.flow.execNode.ai.script;


import cc.autoapi.pucong.auto.flow.core.flow.execNode.entity.node.AiNodeScriptParamIn;
import cc.autoapi.pucong.auto.flow.core.flow.execNode.entity.node.AiNodeScriptParamOut;
import cc.autoapi.pucong.auto.flow.core.flow.execNode.ai.send.AbstractAiSendSendTool;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

/**
 * @description:
 * @author: cong.pu
 * @create: 2024-10-14 10:34
 **/
public abstract class AbstractAiScript implements AiScriptInterface {

    private AbstractAiSendSendTool aiSendSendTool;

    public AbstractAiSendSendTool getAiSendSendTool() {
        return aiSendSendTool;
    }

    public void setAiSendSendTool(AbstractAiSendSendTool aiSendSendTool) {
        this.aiSendSendTool = aiSendSendTool;
    }

    @Override
    public void initAiTool(AbstractAiSendSendTool aiSendSendTool) {
        this.aiSendSendTool = aiSendSendTool;
    }

    public String getOuts(List<AiNodeScriptParamOut> outs) {
        StringBuffer sbf = new StringBuffer();
        if (outs != null && outs.size() > 0) {
            for (AiNodeScriptParamOut out : outs) {
                sbf.append("数据类型：");
                sbf.append(out.getDateType().getName());
                sbf.append("，参数编码：");
                sbf.append(out.getParamCode());
                sbf.append("，参数描述：");
                if (StringUtils.isNotBlank(out.getDesc())) {
                    sbf.append(out.getDesc());
                } else {
                    sbf.append("无");
                }
                sbf.append("\n");
            }
        } else {
            sbf.append("无");
        }
        return sbf.toString();
    }

    public String getIns(List<AiNodeScriptParamIn> ins) {
        StringBuffer sbf = new StringBuffer();
        if (ins != null && ins.size() > 0) {
            for (AiNodeScriptParamIn in : ins) {
                sbf.append("数据类型：");
                sbf.append(in.getDateType().getName());
                sbf.append("，参数编码：");
                sbf.append(in.getParamCode());
                sbf.append("，参数描述：");
                if (StringUtils.isNotBlank(in.getDesc())) {
                    sbf.append(in.getDesc()).append("\n");
                } else {
                    sbf.append("无");
                }
                sbf.append("\n");
            }
        } else {
            sbf.append("无");
        }
        return sbf.toString();
    }
}
